package com.itheima.Object;

import java.io.*;

public class Demo01 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {

        //将对象序列化到文件中
        Student stu = new Student("zhangsan",23,"南京");
        //创建序列化对象
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("20240417\\a.txt"));
        oos.writeObject(stu);
        oos.close();

        //反序列化
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("20240417\\a.txt"));
       Student s1 = (Student)ois.readObject();
        System.out.println(s1);
        ois.close();


    }
}
